package com.itcat.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itcat.mysql.pojo.PmsMemberPrice;
import com.itcat.mysql.pojo.PmsSkuStock;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author 小心触碰的电脑
 * @description 针对表【pms_member_price(商品会员价格表)】的数据库操作Mapper
 * @createDate 2022-04-03 16:09:13
 * @Entity com.itcat.mysql.pojo.PmsMemberPrice
 */
@Mapper
public interface PmsMemberPriceMapper extends BaseMapper<PmsMemberPrice> {

    @Insert({"<script> " +
            "insert into pms_member_price  ( product_id, member_level_id, member_price,  member_level_name)values" +
            " <foreach collection='list' item='item' index='index' separator=',' > " +
            "( #{item.productId}, #{item.memberLevelId} , #{item.memberPrice} , #{item.memberLevelName}) " +
            "</foreach>" +
            "</script>"})
    int batchInsert(@Param("list") List<PmsMemberPrice> list);

    @Update({"<script> " +
            "<foreach collection='list' item='item' index='index' separator=';'> " +
            "UPDATE pms_member_price " +
            "SET product_id = #{item.productId}, member_level_id= #{item.memberLevelId}, member_price = #{item.memberPrice} ,member_level_name = #{item.memberLevelName} " +
            "WHERE id = #{item.id} </foreach> </script>"})
    int batchUpdate(@Param("list") List<PmsMemberPrice> list);

}




